#pragma once

#ifdef _DEBUG
#	define DEBUG(format, ...) fprintf(stderr, format, ##__VA_ARGS__)
#else
#	define DEBUG(format, ...)
#endif

#ifndef SAFE_DEL
#    define SAFE_DEL(x) if ( NULL!=x ) { delete x; x=NULL; }
#endif

#ifndef SAFE_DELA
#    define SAFE_DELA(x) if(NULL!=x){delete [] x;x=NULL;}
#endif

#ifndef ACCESSOR
#    define ACCESSOR(x, type) GETTER(x, type) \
                              SETTER(x, type)
#endif

#ifndef SETTER
#    define SETTER(x, type) inline void Set_##x(const type pData) { x=pData; }
#endif

#ifndef GETTER
#    define GETTER(x, type) GETTER_LEFT (x, type) \
                            GETTER_RIGHT(x, type)
#endif

#ifndef GETTER_RIGHT
#    define GETTER_RIGHT(x, type) inline const type& Get_##x(void) const { return x; }
#endif

#ifndef GETTER_LEFT
#    define GETTER_LEFT(x, type) inline type& Get_##x(void) { return x; }
#endif

//NOTE: this one is not safe for no boundry check
#ifndef ACCESSOR_IDX
#    define ACCESSOR_IDX(x, type) GETTER_IDX(x, type) \
                                  SETTER_IDX(x, type)
#endif

#ifndef SETTER_IDX
#    define SETTER_IDX(x, type) inline void Set_##x(const type pData, const UINT pIdx) { x[pIdx]=pData; }
#endif

#ifndef GETTER_IDX
#    define GETTER_IDX(x, type) GETTER_IDX_RIGHT(x, type) \
                                GETTER_IDX_LEFT (x, type)
#endif

#ifndef GETTER_IDX_RIGHT
#    define GETTER_IDX_RIGHT(x, type) inline const type& Get_##x(const UINT pIdx) const { return x[pIdx]; }
#endif

#ifndef GETTER_IDX_LEFT
#    define GETTER_IDX_LEFT(x, type) inline type& Get_##x(const UINT pIdx) { return x[pIdx]; }
#endif

#ifndef GETBEGIN
#    define GETBEGIN(x, type) inline type* begin_##x(void) { return x; }
#endif

#ifndef GETENDER
#    define GETENDER(x, cnt, type) inline type* end_##x(void) { return x+cnt; }
#endif
